#!/bin/bash
if [ $# -ne 4 ]
then
	echo arg length $#
	echo "Requires feature_matrix.tsv, feature_associations.tsv, pvalue_cutoff, dataset_label"
	exit
fi
feature_matrix_file=$1
associations_file=$2
pvalue_cutoff=$3
dataset_label=$4

echo begin processing $(date)
/tools/bin/python2.5 createSchemaFromTemplate.py $dataset_label ../sql/create_schema_rfex_template.sql
echo begin parsing and loading features and sample values $(date) for $feature_matrix_file
/tools/bin/python2.5 parse_features_rfex.py $feature_matrix_file $dataset_label
echo parsed and loaded features begin processing associations $(date) for $associations_file
/tools/bin/python2.5 parse_associations_rfex.py $feature_matrix_file $associations_file $dataset_label $pvalue_cutoff
echo parsed and loaded associations, create materialized view $(date)
/tools/bin/python2.5 createSchemaFromTemplate.py $dataset_label ../sql/populate_mv_rf_associations_template.sql
echo populated materialize view $(date)
/tools/bin/python2.5 update_rgex_dataset.py $dataset_label
echo registered dataset to regulome explorer repository, program done $(date)

